package cn.kuick.match8.test3;

import java.util.Scanner;

public class DistributeLand {

	public static int findMaxVal(int[][] lands, int i, int j) {
		int[][] maxVals = new int[i][j];
		
		
		maxVals[i][j] = Math.max(maxVals[i-1][j], maxVals[i][j-1]);
		
		return 0;
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		try {
			int n = scan.nextInt();
			int m = scan.nextInt();
			
			int[][] lands = new int[n][m];
			
			for(int i=1;i<=n;i++){
				String str = scan.next();
				char[] strchar = str.toCharArray();
				for(int j=1;j<=m;j++){
					lands[i][j] = strchar[j-1]-'0';
				}
			}
			
			int maxVal = findMaxVal(lands, 3, 3);
			
			System.out.println(maxVal);
		} finally {
			scan.close();
		}
	}
}
